** 	Replication .do file for                                                                   **
** 	Byers & Shay "The Electoral Connection, State AG, and the Dynamics of Incarceration Rates" ** 	
**	Journal of Public Policy - Appendix                                                	       **

* This code will replicate the results included in the Appendix. *
* Please cite the above article if you use these data or code *
* All the analyses were done using Stata (Version 16).*

* Set working directory to load the data: Note that users will need to input the relevant file path
		cd "/Users/user/Desktop"
		import delimited "Byers_and_Shay_JPP.csv", clear

		
*****************************
*Main Text Analysis
******************************

*Declare Dataset and Panel ID
xtset fip year

***Appendix A***

*Model 1
xtreg dv i.year urban c.citizen govt_ideo c.crime  law_enforcement_spending  percentblack povrate gsp income state_revenue if elected==0, fe vce(cluster fip)
estat ic

*Model 2
xtreg dv i.year urban c.citizen govt_ideo c.crime  law_enforcement_spending  percentblack povrate gsp income state_revenue if elected==1, fe vce(cluster fip)
estat ic

***Table B***

*Table B1
summarize dv urban leg citizen govt_ideo crime elected  law_enforcement_spending south  percentblack povrate gsp income state_revenue

*Table B2
summarize dv urban leg citizen govt_ideo crime elected  law_enforcement_spending south  percentblack povrate gsp income state_revenue if elected==0

*Table B3
summarize dv urban leg citizen govt_ideo crime elected  law_enforcement_spending south  percentblack povrate gsp income state_revenue if elected==1

*Table B4
correlate dv urban leg citizen govt_ideo crime elected  law_enforcement_spending south  percentblack povrate gsp income state_revenue

***Table C***

*The "Method" column was identified using The Book of the States and verified with additional sources.

*The "Unique AG" variable was compiled from multiple sources.

*For "Crime SD," use the following code:
tabstat crime, by(fip) stats(sd) 

***Table D***
xtreg dv i.year urban leg c.citizen govt_ideo c.crime##c.elected_term c.crime##elected_noterm  law_enforcement_spending south  percentblack povrate gsp income state_revenue, mle
estat ic



